"""
演示json数据和python字典的相互转换
"""
import json

data = [{"name":"访问","age":16},{"name":"g发啊ym","age":17},{"name":"酸到的","age":18}]

# 通过dumps将数据转为json数据,ensure_ascii表示是否转为ascii码
json_str = json.dumps(data,ensure_ascii=False)
print(json_str)
print(type(json_str))

# 通过loads方法把json数据转化为 python列表或字典
s = '[{"name":"访问","age":16},{"name":"g发啊ym","age":17},{"name":"酸到的","age":18}]'
l = json.loads(s)
print(l)
print(type(l))